package com.boot.security.server.dao.user;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.user.TswMycoupons;

@Mapper
public interface TswMycouponsDao {

    @Select("select * from tsw_mycoupons t where t.id = #{id}")
    TswMycoupons getById(Long id);

    @Delete("delete from tsw_mycoupons where id = #{id}")
    int delete(Long id);

    int update(TswMycoupons tswMycoupons);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_mycoupons(user_id, coupon_id, coupon_state, get_time, last_valid_time, coupon_note, coupon_remark) values(#{userId}, #{couponId}, #{couponState}, #{getTime}, #{lastValidTime}, #{couponNote}, #{couponRemark})")
    int save(TswMycoupons tswMycoupons);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswMycoupons> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
